package com.iiiss.template.ssg.beans;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.iiiss.template.ssh.core.beans.IEvent;
import com.iiiss.template.ssg.common.BaseBean;

/*
 * TemplateSSG - com.iiiss.template.ssg.beans - GaeJpaEvent.java
 * 
 * Copyright (C) 2011  Mingye Cheng <Cheng, Mingye at GMAIL>
 * 
 * GaeJpaEvent.java is part of <iiiStudio Template Framework> project.
 * This project is hosted at <http://iiiss-template-ssh.googlecode.com>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Revision history:
 * [2011-5-30] Mingye Cheng - Initial version established.
 * [2011-5-31] Mingye Cheng - Modified for GoogleAppEngine. (Using java.util.Date)
 * [2011-7-6] Mingye Cheng - Moved to 'template.ssg' package,
 *                           Renamed to 'GaeJpaEvent'.
 */
@Entity
public class GaeJpaEvent extends BaseBean implements IEvent {
	@Temporal(TemporalType.TIMESTAMP)
	private Date time;

	@Basic
	private String title;

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public boolean equals(Object obj) {
		return (getKey().equals(((GaeJpaEvent) obj).getKey()))
				&& (getTime().equals(((GaeJpaEvent) obj).getTime()))
				&& (getTitle().equals(((GaeJpaEvent) obj).getTitle()));
	};

	public String toString() {
		return "Event " + getKey() + " (" + getTime() + ") " + getTitle();
	}
}
